import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

public class BookTest {
    public static void main(String[] args) throws ParseException {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        Book [] books = new Book[2];
        for (int i=0;i<2;i++){
            Book book = new Book();
            Scanner scanner = new Scanner(System.in);
            System.out.println("请输入图书编号：");
            int  id=scanner.nextInt();
            book.setBookId(id);
            System.out.println("请输入图书的价格：");
            double  price=scanner.nextDouble();
            book.setBookPrice(price);
            System.out.println("请输入图书的出版日期(yyyy-MM-dd)：");
            String next = scanner.next();
            Date date = simpleDateFormat.parse(next);
            book.setPublishData(date);
            books[i]=book;
        }
        for (Book book:books){
            System.out.println("图书的编号"+book.getBookId());
            DecimalFormat  decimalFormat=new DecimalFormat("###.##");
            String dataStr = decimalFormat.format(book.getBookPrice());
            if (dataStr.indexOf(".")==-1){
                dataStr=dataStr+".00";
            }
            System.out.println("图书的价格"+dataStr);
            String format = simpleDateFormat.format(book.getPublishData());
            System.out.println("图书的出版日期"+format);
        }

    }
}
